<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Category_model extends CI_Model {
	function get_list() {
		$this->db->where('status', DB_STATUS_NORMAL);
		$this->db->order_by('order', 'ASC');
		$this->db->order_by('id', 'ASC');
		$query = $this->db->get('category');
		log_message('debug', $this->db->last_query());
		
		return $query->result_array();
	}
	
	function get_by_id($category_id) {
		$this->db->where('id', $category_id);
		$this->db->where('status', DB_STATUS_NORMAL);
		$query = $this->db->get('category');
		log_message('debug', $this->db->last_query());
		
		$count = $this->db->count_all_results();
		return $count == 1 ? $query->row_array() : NULL;
	}
}